package 反射;

import java.beans.IntrospectionException;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Person implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 
	 */
	private String name;
	private int age;
	// get/set方法

	public Person(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}

	public String getName(String s) {
		return s + ":" + name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public static void main(String[] args) throws IntrospectionException, IllegalAccessException,
			IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
		Person person = new Person("luoxn28", 23);
		Class<? extends Person> clazz = person.getClass();
		Method method = clazz.getDeclaredMethod("getName", String.class);
		Object value = method.invoke(person, "hello");
		System.out.println(value);
	}

}
